package com.wanmait.deliverymangementsystem.managecontroller;

import com.github.pagehelper.PageInfo;
import com.wanmait.deliverymangementsystem.pojo.Nickname;
import com.wanmait.deliverymangementsystem.service.NicknameService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("manage")
public class ManageNickNameController {
    @Resource
    private NicknameService nicknameService;
    //所有
    @GetMapping("nickNameList")
    @ModelAttribute("nicknamePageInfo")
    public PageInfo<Nickname> nickNameList(){
        return nicknameService.findAll(0);
    }
    //删除
    @GetMapping("delNick")
    public String delNick(Integer id){
        nicknameService.deleteByPrimaryKey(id);
        return "redirect:/manage/nickNameList";
    }

    //添加页面
    @GetMapping("addNickName")
    public void addNickName(){

    }
    @PostMapping("addNickName")
    public String addNickName(Nickname nickname){
        nicknameService.insert(nickname);
        return "redirect:/manage/nickNameList";
    }
}
